<?php

namespace console;

use \console\core\manager\InstanceManager;

class Config extends InstanceManager
{

    private static $_container = [];

    static function loadBase($filename = '' , $array = false)
    {
        if($array) return self::load($filename)->toArray();else return self::load($filename);
    }

    static function loadItem($filename = '' , $array = false)
    {
        if($array) return self::load($filename,'item')->toArray();else return self::load($filename,'item');
    }
    
    private static function load($file = '' , $type = 'base')
    {
        if(!isset(self::$_container[$type][$file]))
        {
            $path = rtrim($type=='base'?CONSOLE_PATH:ITEM_PATH,'/\\').DIRECTORY_SEPARATOR;
            self::$_container[$type][$file] =  call_user_func("self::PhpConfig","{$path}config/".(ucfirst($file)).".php");
        }

        return self::$_container[$type][$file];
    }
}